package Text1;

/*
 *@Student 张策
 */
public class text1 {
    public static void main(String[] args) {
        Node node1 = new Node("1号");
        Node node2 = new Node("2号");
        Node node3 = new Node("3号");
        node1.next=node2;
        node2.next=node3;
        node3.pre=node2;
        node2.pre=node1;
        Node first=node1;
        Node last=node3;
        //正向
        while (true){
            if(first==null){
                first=node1;
                break;
            }
             System.out.println(first);
            first=first.next;
        }
        //反向
        System.out.println("=======");
        while (true){
            if(last==null){
                last=node3;
                break;
            }
            System.out.println(last);
            last=last.pre;
        }
        Node zc = new Node("张策");
        node1.next=zc;
        zc.next=node2;
        node2.pre=zc;
        zc.pre=node1;
        System.out.println("==========");
        while (true){
            if(first==null){
                first=node1;
                break;
            }
            System.out.println(first);
            first=first.next;
        }
    }
}
class Node{
    public Object name;
    Node next;
    Node pre;

    public Node(Object name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Node{" +
                "name='" + name + '\'' +
                '}';
    }
}
